"""
通过while循环，完成猜数字游戏，完成：
无限次机会，直到猜中为止
每一次猜不中，会提示大了或者小了
猜数字后，提示猜了几次
"""
import random
num = random.randint(1,100)
num_guess = 0
i = 0                                                       # 设置计时器
while num != num_guess:                                     # 设置停止循环条件
    num_guess = input('please input the number you guess')
    num_guess = int(num_guess)
    if num == num_guess:                                    # 判断是否正确
        print('yeah, you guessed the right number')
        print(f'you made a total of {i} guesses')
    else:
        i = i + 1
        print('you did not guess the right number')
        if num_guess < num:                                 # 比较大小
            print('the number you guess < the right number，小了')
        else:
            print('the number you guess > the right number，大了')

